<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: additional_text.php 11 2013-09-21 11:43:11Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 11 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 11:43:11 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

if(isset($_GET['pID']) && isset($_GET['action']) && $_GET['action'] == 'new' || $_GET['action'] == 'edit') {
	chdir('../../');
	require_once('includes/application_top.php');
	
	$title = '';
	$desc = '';
	
	if(isset($_GET['id']) && is_numeric($_GET['id'])) {
		$get_data = $db->db_query("SELECT additional_title, additional_desc FROM ".TABLE_PRODUCTS_ADDITIONAL_TEXT." WHERE additional_id = ".$db->db_prepare($_GET['id']));
		$title = $get_data->fields['additional_title'];
		$desc = $get_data->fields['additional_desc'];
	}
?>	
	<table border="0" width="100%">
		<tr>
			<td width="1" valign="top">Titel:</td>
			<td>
				<input type="text" name="products_additional_title" class="products_additional_title" value="<?php echo $title ?>" /> <em>muss in einen Tab passen</em>
			</td>
			<td width="1" align="right">
				<button class="button" type="button" onclick="get_values('<?php echo $_GET['action'] ?>')"><?php echo BUTTON_SAVE ?></button>
			</td>
		</tr>
		<tr>
			<td valign="top" colspan="3">
				<textarea name="products_additional_description" id="products_additional_description"><?php echo $desc ?></textarea>
			</td>
		</tr>
	</table>
	<input type="hidden" name="" value="<?php echo $_GET['lng'] ?>" class="lng_id" />
	<input type="hidden" name="" value="<?php echo $_GET['id'] ?>" class="add_id" />
	<script type="text/javascript">setTimeout("set_editor();", 200)</script>
<?php
} else {

	function getAdditionals($pID = '', $lng) {
		global $db;
		
		if(empty($pID))
			return;
		
		$c .= '	<div>
					<a class="button dialog_button" href="includes/modules/additional_text.php?pID='.$pID.'&lng='.$lng.'&action=new">
						'.TEXT_ADDITIONAL_TEXT_BUTTON.'
					</a>
				</div>
				<div id="addition_text_container">';
				
		$get_from_db = $db->db_query("SELECT 
											additional_id,
											additional_title,
											additional_desc
										FROM 
											".TABLE_PRODUCTS_ADDITIONAL_TEXT."
										WHERE
											languages_id = '".$lng."'
										AND
											products_id = '".$pID."'");
		
		if($get_from_db->_numOfRows) {
			$c .= '	<table class="dataTable" border="0" width="100%" style="margin-top:10px;" cellpadding="5">';
			$c .= '		<tr class="dataTableHeadingRow">
                			<td class="dataTableHeadingContent">'.TABLE_HEADING_TITLE.'</td>
                			<td class="dataTableHeadingContent" colspan="2">'.TABLE_HEADING_DESC.'</td>
              			</tr>';
			while(!$get_from_db->EOF) {	$rows++;
			
				if ($rows % 2 == 0)	$f = ' class="dataTableRow"';
				else $f = '';
				
				$c .= '	<tr'.$f.' id="row_'.$get_from_db->fields['additional_id'].'">
							<td>
								<b>'.$get_from_db->fields['additional_title'].'</b>
							</td>
							<td>
								'.substr($get_from_db->fields['additional_desc'], 0, 30).'...
							</td>
							<td align="right">
								<a class="button dialog_button" href="includes/modules/additional_text.php?id='.$get_from_db->fields['additional_id'].'&lng='.$lng.'&action=edit">
									'.BUTTON_EDIT.'
								</a> 
								<button class="button" type="button" onclick="xajax_delete_additional('.$get_from_db->fields['additional_id'].')">'.BUTTON_DELETE.'</button>
							</td>
						</tr>';
				$get_from_db->MoveNext();
			}
			$c .= '</table>';
		}
		$c .= '</div>';
		
		return $c;
	}
}